import { ref } from 'vue';
import { Component, Vue } from 'vue-facing-decorator';
import { BasicTree, TreeItem } from '@/components/Tree';
import { getDeptList } from '@/api/demo/system';
/**
 * @program: microservice-central-portal
 * @description: 系统账号管理部门列表部分
 * @author: baiHoo.chen
 * @create: 2022年5月24日
 **/
@Component({ name: 'DeptTree', components: { BasicTree }, emits: ['select'] })
export default class DeptTree extends Vue {
  treeData = ref<TreeItem[]>([]);
  mounted() {
    this.fetch();
  }
  handleSelect(keys) {
    this.$emit('select', keys[0]);
  }
  async fetch() {
    this.treeData.value = (await getDeptList()) as unknown as TreeItem[];
  }
}
